package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.fabu.FabuBean;
import com.lwj.liwanjia.bean.fabu.FzSubBean;
import com.lwj.liwanjia.impl.FabuView;
import com.lwj.liwanjia.model.FabuModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2018/1/14.
 */

public class FabuPresneter {
    private FabuView fabuView;
    private FabuModel fabuModel;

    public FabuPresneter(FabuView fabuView) {
        this.fabuView = fabuView;
        fabuModel = new FabuModel();
    }

    public void submitFabu(Map<String, Object> map, Object object) {
        fabuModel.submitFabu(map, object, new Subscriber<FabuBean>() {
            @Override
            public void onCompleted() {
                fabuView.hideProgress();
            }

            @Override
            public void onError(Throwable e) {
                fabuView.showError((Exception) e);
                fabuView.hideProgress();
            }

            @Override
            public void onNext(FabuBean fabuBean) {
                fabuView.submitFabu(fabuBean);
            }

            @Override
            public void onStart() {
                super.onStart();
                fabuView.showProgress();
            }
        });
    }
}
